{extend name="_public/table_page" /}

{block name="search-form"}
<div class="layui-row">
    <form class="layui-form layui-col-md12 we-search" action="{:request()->url()}" method="get">
        <div class="layui-inline">
            <input type="text" name="username" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="{$Request.get.username|default=''}">
        </div>
        <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
    </form>
</div>
{/block}

{block name="button"}
<div class="weadmin-block" style="overflow: hidden">
    {if auth("$classuri/del")}
    <button class="layui-btn layui-btn-xs" data-post-batch='{:url("$classuri/del")}' data-title="批量删除">批量删除</button>
    {/if}
    {if auth("$classuri/add")}
    <button class="layui-btn layui-btn-xs" data-modal='{:url("$classuri/add")}' data-title="添加用户">添加用户</button>
    {/if}
</div>
{/block}

{block name="table"}
<table class="layui-table" lay-even lay-skin="line" lay-size="sm">
    <thead>
    <tr>
        <th>
            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
        </th>
        <th>id</th>
        <th>账号</th>
        <th>姓名</th>
        <th>角色</th>
        <th>状态</th>
        <th>最后登录</th>
        <th>操作</th>
    </thead>
    <tbody>
    {volist name="list" id="vo"}
    <tr>
        <td>
            <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='{$vo.id}'><i class="layui-icon">&#xe605;</i></div>
        </td>
        <td>{$vo.id}</td>
        <td>{$vo.username}</td>
        <td>{$vo.name}</td>
        <td>
            {volist name="vo.roles" id="role"} {$role.title} {/volist}
        </td>
        <td>{:$vo.state?'启用':'禁用'}</td>
        <td>{$vo.last_login|date='Y-m-d H:i:s'}</td>
        <td>
            <div class="layui-btn-group">
                {if auth("$classuri/edit")}
                <button class="layui-btn layui-btn-xs" href="javascript:;" data-title="编辑用户" data-modal='{:url("$classuri/edit",["id"=>$vo.id])}'>
                    编辑
                </button>
                {/if}
                {if auth("$classuri/role")}
                <button class="layui-btn layui-btn-xs" href="javascript:;" data-title="授予角色" data-modal='{:url("$classuri/role",["id"=>$vo.id])}'>
                    角色
                </button>
                {/if}
                {if auth("$classuri/password")}
                <button class="layui-btn layui-btn-xs" href="javascript:;" data-title="重置密码" data-modal='{:url("$classuri/password",["id"=>$vo.id])}'>
                    密码
                </button>
                {/if}
                {if auth("$classuri/change")}
                <button class="layui-btn layui-btn-xs layui-btn-{:$vo.state?'warm':'primary'}" href="javascript:;" data-confirm="确定操作该条数据吗？"
                        data-post='{:url("$classuri/change")}' data-param="id={$vo.id}&state={:abs($vo.state-1)}">
                    {:$vo.state?'禁用':'启用'}
                </button>
                {/if}
                {if auth("$classuri/del")}
                <button class="layui-btn layui-btn-xs" href="javascript:;"
                        data-confirm="确定要删除吗！" data-post='{:url("$classuri/del")}' data-param="ids={$vo.id}">
                    删除
                </button>
                {/if}
            </div>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>
{$page|raw}
{/block}
